

****************************************************
****** 			LOCKING DOWN VIOLENCE	      ******
******         Brancati, Birnir, Idlbi 		  ******
******  Statistical Analysis Replication Code ******
****** 					TABLE 2 			  ******
****************************************************


** GOVERNORATE LEVEL ANALYSIS**

use "LDV_GOVLEVEL.dta"

*Time-Set the Data
gen isogovadmcode = govadmcode + 100 if country == "Republic of Iraq"
replace isogovadmcode = govadmcode + 1000 if country == "Arab Republic of Egypt"
replace isogovadmcode = govadmcode + 100000 if country == "Syrian Arab Republic"

xtset isogovadmcode week

*Generate Country Indicators* 
gen syria  = 0 
replace syria = 1 if iso == 760 
gen iraq = 0 
replace iraq = 1 if iso  == 368
gen egypt = 0 
replace egypt = 1 if iso  == 818

*curfewstri internalbanstri curfewsdi internalbansdi ISIScurfewsdi nonISIScurfewsdi ISISinternalbansdi nonISISinternalbansdi ramadan covid19eracase covid19eradeath oilprice uscovid19eradeath uscovidcumdeathcdc uscovidcumdeathswho covidcumdeathswho covidcumdeathsdatewho
*generate lags*
sort iso week 
foreach  variable of varlist  ramadan covid19eracase covid19eradeath oilprice uscovid19eradeath uscovidcumdeathcdc uscovidcumdeathdatecdc uscovidcumdeathswho internalbanstri curfewsdi curfewstri covidcumdeathswho covidcumdeathsdatewho usforces iranforces sdfforces gosforces goiforces pmfforces goeforces securityaidtotal economicaidusaid humanitarianaidunfts covidaidunfts covidaidstate internalbansdi ISIScurfewsdi nonISIScurfewsdi nonISISnternalbansdi nonISISneighbansdi {
bysort iso: gen `variable'_lag = `variable'[_n-1]
}
destring, replace

***** *** *** *** *** *** *** *** *** *** *** ** * ANALYSIS ***** *** *** *** *** *** *** *** *** *** *** ***** *** *** *** 


*Model 6, DV: ISIS-initiated Violent Events (includes likely). IV: COVID-19 Era  (Curfews) 
xtnbreg isisandlikely_wk covid19eradeath_lag vsisis_wk_lag oilprice_lag nonISIScurfewsdi_lag ISIScurfewsdi_lag ramadan iraq egypt, re
outreg2 using Table2bGOV, replace
test nonISIScurfewsdi_lag ISIScurfewsdi_lag
margins, at(nonISIScurfewsdi_lag=0 ISIScurfewsdi_lag=0) predict(nu0)
margins, at(nonISIScurfewsdi_lag=1 ISIScurfewsdi_lag=0) predict(nu0)
margins, at(nonISIScurfewsdi_lag=0 ISIScurfewsdi_lag=1) predict(nu0)

*Model 7, DV: ISIS-initiated Violent Events (includes likely). IV: COVID-19 Era  (Curfews) [and Interaction population]

gen nonISIScurfewsdi_pop = nonISIScurfewsdi_lag*population
gen ISIScurfewsdi_pop = ISIScurfewsdi_lag*population
xtnbreg isisandlikely_wk covid19eradeath_lag vsisis_wk_lag oilprice_lag nonISIScurfewsdi_lag nonISIScurfewsdi_pop ISIScurfewsdi_pop ISIScurfewsdi_lag population ramadan iraq egypt, re
outreg2 using Table2bGOV, append
test nonISIScurfewsdi_pop nonISIScurfewsdi_lag pop 
test nonISIScurfewsdi_pop nonISIScurfewsdi_lag pop ISIScurfewsdi_lag ISIScurfewsdi_pop 

*Figure 1a* 
predict zhat1, nu0
margins, at(nonISIScurfewsdi_pop=0 nonISIScurfewsdi_lag=0 pop=1500000 ISIScurfewsdi_lag=0 ISIScurfewsdi_pop=0 iraq=1 egypt=0) predict(nu0)
margins, at(nonISIScurfewsdi_pop=1500000 nonISIScurfewsdi_lag=1 pop=1500000  ISIScurfewsdi_lag=0 ISIScurfewsdi_pop=0 iraq=1 egypt=0) predict(nu0)
margins, at(nonISIScurfewsdi_pop=0 nonISIScurfewsdi_lag=0 pop=8100000 ISIScurfewsdi_lag=0 ISIScurfewsdi_pop=0 iraq=1 egypt=0) predict(nu0)
margins, at(nonISIScurfewsdi_pop=8100000 nonISIScurfewsdi_lag=1 pop=8100000 ISIScurfewsdi_lag=0 ISIScurfewsdi_pop=0 iraq=1 egypt=0) predict(nu0)


margins, at(nonISIScurfewsdi_pop=0 nonISIScurfewsdi_lag=0 pop=2908491 ISIScurfewsdi_lag=0 ISIScurfewsdi_pop=0) predict(nu0)
margins, at(nonISIScurfewsdi_pop=0 nonISIScurfewsdi_lag=0 pop=8126755 ISIScurfewsdi_lag=0 ISIScurfewsdi_pop=0) predict(nu0)
margins, at(nonISIScurfewsdi_pop=2908491 nonISIScurfewsdi_lag=1 pop=2908491 ISIScurfewsdi_lag=0 ISIScurfewsdi_pop=0) predict(nu0)
margins, at(nonISIScurfewsdi_pop=8126755 nonISIScurfewsdi_lag=1 pop=8126755 ISIScurfewsdi_lag=0 ISIScurfewsdi_pop=0) predict(nu0)

*Baghdad
tabstat zhat1 if nonISIScurfewsdi_pop==8126755 & nonISIScurfewsdi_lag==1 & pop==8126755 & ISIScurfewsdi_lag==0 & ISIScurfewsdi_pop==0
tabstat zhat1 if nonISIScurfewsdi_pop==0 & nonISIScurfewsdi_lag==0 & pop==8126755 & ISIScurfewsdi_lag==0 & ISIScurfewsdi_pop==0

*Najaf*
tabstat zhat1 if nonISIScurfewsdi_pop==2908491 & nonISIScurfewsdi_lag==1 & pop==2908491  & ISIScurfewsdi_lag==0 & ISIScurfewsdi_pop==0
tabstat zhat1 if nonISIScurfewsdi_pop==0 & nonISIScurfewsdi_lag==0 & pop==2908491  & ISIScurfewsdi_lag==0 & ISIScurfewsdi_pop==0



*Model 8, DV: ISIS-initiated Violent Events (includes likely). IV: COVID-19 Era  (Travel Bans instead of Curfews)
xtnbreg isisandlikely_wk covid19eradeath_lag vsisis_wk_lag oilprice_lag nonISISinternalbansdi_lag ISISinternalbansdi_lag ramadan iraq egypt, re
outreg2 using Table2bGOV, append
test nonISISinternalbansdi_lag ISISinternalbansdi_lag
xtnbreg isisandlikely_wk vsisis_wk_lag oilprice_lag nonISISinternalbansdi_lag ISISinternalbansdi_lag ramadan iraq egypt, re
margins, at(nonISISinternalbansdi_lag=0 ISISinternalbansdi_lag=0) predict(nu0)
margins, at(nonISISinternalbansdi_lag=1 ISISinternalbansdi_lag=0) predict(nu0)
margins, at(nonISISinternalbansdi_lag=0 ISISinternalbansdi_lag=1) predict(nu0)


* Model 9, DV: ISIS-initiated Violent Events (includes likely). IV: COVID-19 Era  (Travel Bans instead of Curfews) [and Interaction base]

gen nonISISinternalbansdi_base = nonISISinternalbansdi_lag*base
gen ISISinternalbansdi_base = ISISinternalbansdi_lag*base
xtnbreg isisandlikely_wk covid19eradeath_lag vsisis_wk_lag oilprice_lag nonISISinternalbansdi_lag ISISinternalbansdi_lag ISISinternalbansdi_base nonISISinternalbansdi_base base ramadan iraq egypt, re
outreg2 using Table2bGOV, append
test nonISISinternalbansdi_base base nonISISinternalbansdi_lag
test nonISISinternalbansdi_base nonISISinternalbansdi_lag base ISISinternalbansdi_lag ISISinternalbansdi_base

*Figure 1b* 
margins, at(nonISISinternalbansdi_base=0 nonISISinternalbansdi_lag=0 base=0 ISISinternalbansdi_lag=0) predict(nu0)
margins, at(nonISISinternalbansdi_base=0 nonISISinternalbansdi_lag=0 base=1 ISISinternalbansdi_lag=0) predict(nu0)
margins, at(nonISISinternalbansdi_base=0 nonISISinternalbansdi_lag=1 base=0 ISISinternalbansdi_lag=0) predict(nu0)
margins, at(nonISISinternalbansdi_base=1 nonISISinternalbansdi_lag=1 base=1 ISISinternalbansdi_lag=0) predict(nu0)

predict zhat2, nu0




